package com.common.response;

import com.common.utils.Constant;

import java.util.HashMap;
import java.util.Map;

public class ResponseVO {

    public ResponseVO() {
        content = new HashMap<>();
    }

    private Integer state;

    private String msg;

    private Map<String, Object> content;

    public void setState(Integer state) {
        this.state = state;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public Integer getState() {
        return state;
    }

    public Map<String, Object> getContent() {
        return content;
    }

    public void setContent(Map<String, Object> content) {
        this.content = content;
    }

    public ResponseVO put(String key, Object value) {
        this.content.put(key, value);
        return this;
    }

    public Object get(String key) {
        return this.content.get(key);
    }

    public ResponseVO success() {
        this.setState(Constant.SUCCESS);
        return this;
    }

    public ResponseVO success(String msg) {
        this.setState(Constant.SUCCESS);
        this.setMsg(msg);
        return this;
    }

    public ResponseVO fail() {
        this.setState(Constant.FAIL);
        return this;
    }

    public ResponseVO fail(String msg) {
        this.setState(Constant.FAIL);
        this.setMsg(msg);
        return this;
    }

    public ResponseVO error() {
        this.setState(Constant.ERROR);
        return this;
    }

    public ResponseVO error(String msg) {
        this.setState(Constant.ERROR);
        this.setMsg(msg);
        return this;
    }

    public ResponseVO exception() {
        this.setState(Constant.EXCEPTION);
        return this;
    }

    public ResponseVO exception(String msg) {
        this.setState(Constant.EXCEPTION);
        this.setMsg(msg);
        return this;
    }
}

